//
//  CS_QueryPanel_ConditionView.m
//  CSUIKit
//
//  Created by 浙大网新中研软件 on 2017/11/10.
//

#import "CS_QueryPanel_ConditionView.h"
#import "CS_QueryPanel_MultiSelectView.h"
#import "CS_QueryPanel_SingleSelectView.h"
#import "CS_QueryPanel_DateTimeRangeView.h"
#import "CS_QueryPanel_OtherConditionsView.h"

@interface CS_QueryPanel_ConditionView()

//灰色按钮，点击隐藏查询条件界面
@property (nonatomic, strong) UIButton *maskButton;

@end

@implementation CS_QueryPanel_ConditionView

+(id)queryPanel_ConditionView:(CSConditionModel *)conditionModel{
    
    CS_QueryPanel_ConditionView *conditionView;
    
    if (conditionModel.type == CSViewType_PageSingleView) {
        
        //单选
        conditionView = [CS_QueryPanel_SingleSelectView new];
        conditionView.conditionModel = conditionModel;
        
    }else if(conditionModel.type == CSViewType_TimeRangeView){
        
        //日期范围
        conditionView = [CS_QueryPanel_DateTimeRangeView new];
        conditionView.conditionModel = conditionModel;
        
    }else if(conditionModel.type == CSViewType_PageMulityView){
        
        //多选
        conditionView = [CS_QueryPanel_MultiSelectView queryPanel_MultiSelectView:conditionModel];
        
    }else{
        
        //其他筛选条件
        conditionView = [CS_QueryPanel_ConditionView new];
        
    }
    
    return conditionView;
}

/**
 * 其他查询条件
 */
+(id)queryPanel_ConditionViewForOther:(NSArray *)otherConditionModels{
    
    CS_QueryPanel_OtherConditionsView *conditionView = [CS_QueryPanel_OtherConditionsView new];
    conditionView.otherConditions = otherConditionModels;
    return conditionView;
    
}

-(UIButton *)maskButton{
    
    if (_maskButton == nil) {
        _maskButton = [[UIButton alloc] init];
        _maskButton.backgroundColor = [UIColor blackColor];
        _maskButton.layer.opacity = 0.3;
        [_maskButton addTarget:self action:@selector(maskButtonClick) forControlEvents:UIControlEventTouchUpInside];
        _maskButton.frame = CGRectMake(0, 0, kWindowW, HEIGHT_REST_CONDITION_VIEW);
    }
    return _maskButton;
    
}

-(void)maskButtonClick{
    
    if (self.onConditionConfigureCancelBlock) {
        self.onConditionConfigureCancelBlock();
    }
    
}


@end
